<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$setting=$this->setting;
$return['page']=$this->plugin_setting('page');
set_html('title',$return['page']['qrcodetitle']?:'我的二维码');
if($_RQ['op']=='main'){
	if($setting['closed_qrcode']){
		exi('没有开启推广二维码','error','/index/');
	}
	if($_SESSION['onemerchid']){
		$poster=$this->plugin_setting('poster'.$_SESSION['onemerchid']);
	}else{
		$poster=$this->plugin_setting('poster');
	}
	if($poster['isopen']==1){
		exi('','','/build/');
	}
	$member=$this->get('member',array('merchid'=>$_SESSION['onemerchid'],'mid'=>$_SESSION['uid']));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$setting['tcommission']=$setting['tcommission']?$setting['tcommission']:'佣金';
	if($setting['become_child']==1){
		$setting['t1']='如果您的好友下单，';
	}else{
		$setting['t1']='如果您的好友下单并付款，';
	}
	if(!$setting['share_help'] && $setting['isyidong']){
		$setting['share_help']='分享后会带有独有的推荐码，您的好友访问之后，系统会自动检测并记录客户关系。如果您的好友已被其他人抢先发展成了队员，您依然可以把他转移成为您的队员，以最近发展成为队员为准';
	}elseif(!$setting['share_help']){
		$setting['share_help']='分享后会带有独有的推荐码，您的好友访问之后，系统会自动检测并记录客户关系。如果您的好友已被其他人抢先发展成了队员，他就不能成为您的队员，以最早发展成为队员为准';
	}
	$setting['torder']=$setting['torder']?$setting['torder']:'团队订单';
	$setting['tmydown']=$setting['tmydown']?$setting['tmydown']:'我的队员';
	$setting['twithdraw']=$setting['twithdraw']?$setting['twithdraw']:'提现';	
	$return['setting']=$setting;
	$url=custom_url('jy_merch2fee/myhome/main/mid='.$_SESSION['uid'].'&fromuser='.$_SESSION['uid'].'&onemerchid='.$_SESSION['onemerchid'],true);
	$return['qrcode']=cfc('tools')->createqrcode($url,'250',true);
	$return['qrcode']=tomedia($return['qrcode']);
	$image=ROOT_AT.'oss/'.$_SESSION['uniacid'].'/images/jy_merch2fee/wx'.$_SESSION['onemerchid'].'appid'.$_SESSION['uid'].'.jpg';
	if(!file_exists($image)){
		$url='/jy_merch2fee/myhome/index?mid='.$_SESSION['uid'].'&fromuser='.$_SESSION['uid'].'&onemerchid='.$_SESSION['onemerchid'];
		$wxapp=pdo_get('core_account_wxapp',array('id'=>$_SESSION['wxapp_id'],'uniacid'=>$_SESSION['uniacid']));
		$res=model('core/wxapp')->appcode($url,$wxapp['appid'],$wxapp['appsecret'],200);
		$path=ROOT_AT.'oss/'.$_SESSION['uniacid'].'/images/jy_merch2fee/';
		if(!file_exists($path)){
			mkdir($path,0700, true);
		}
		file_put_contents($image,$res);
	}
	$return['appcode'] = 'oss/'.$_SESSION['uniacid'].'/images/jy_merch2fee/wx'.$_SESSION['onemerchid'].'appid'.$_SESSION['uid'].'.jpg';
	$return['sharedata']=array(
			'title'=>$setting['teamshare_title']?$setting['teamshare_title']:'快来加入我的团队吧！',
			'desc'=>$setting['teamshare_desc']?:'加入我的团，第一时机了解活动，优惠多多，活动多多！',
			'link'=>custom_url('jy_merch2fee/myhome/main/fromuser='.$_SESSION['uid'].'&onemerchid='.$_SESSION['onemerchid'],true),
			'imgUrl'=>tomedia($member['avatar']),
	);
	exi($return);
}

?>